001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.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.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.service.persistence.BatchSessionUtil;
041    import com.liferay.portal.service.persistence.ResourcePersistence;
042    import com.liferay.portal.service.persistence.UserPersistence;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import com.liferay.portlet.mobiledevicerules.NoSuchRuleException;
046    import com.liferay.portlet.mobiledevicerules.model.MDRRule;
047    import com.liferay.portlet.mobiledevicerules.model.impl.MDRRuleImpl;
048    import com.liferay.portlet.mobiledevicerules.model.impl.MDRRuleModelImpl;
049    
050    import java.io.Serializable;
051    
052    import java.util.ArrayList;
053    import java.util.Collections;
054    import java.util.List;
055    
056    /**
057     * The persistence implementation for the m d r rule service.
058     *
059     * <p>
060     * Caching information and settings can be found in <code>portal.properties</code>
061     * </p>
062     *
063     * @author Edward C. Han
064     * @see MDRRulePersistence
065     * @see MDRRuleUtil
066     * @generated
067     */
068    public class MDRRulePersistenceImpl extends BasePersistenceImpl<MDRRule>
069            implements MDRRulePersistence {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link MDRRuleUtil} to access the m d r rule persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
074             */
075            public static final String FINDER_CLASS_NAME_ENTITY = MDRRuleImpl.class.getName();
076            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List1";
078            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List2";
080            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
081                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, MDRRuleImpl.class,
082                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
083                            new String[] {
084                                    String.class.getName(),
085                                    
086                            "java.lang.Integer", "java.lang.Integer",
087                                    "com.liferay.portal.kernel.util.OrderByComparator"
088                            });
089            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
090                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, MDRRuleImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
092                            new String[] { String.class.getName() },
093                            MDRRuleModelImpl.UUID_COLUMN_BITMASK);
094            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
095                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, Long.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
097                            new String[] { String.class.getName() });
098            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
099                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, MDRRuleImpl.class,
100                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
101                            new String[] { String.class.getName(), Long.class.getName() },
102                            MDRRuleModelImpl.UUID_COLUMN_BITMASK |
103                            MDRRuleModelImpl.GROUPID_COLUMN_BITMASK);
104            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
105                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, Long.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
107                            new String[] { String.class.getName(), Long.class.getName() });
108            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPID =
109                    new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
110                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, MDRRuleImpl.class,
111                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRuleGroupId",
112                            new String[] {
113                                    Long.class.getName(),
114                                    
115                            "java.lang.Integer", "java.lang.Integer",
116                                    "com.liferay.portal.kernel.util.OrderByComparator"
117                            });
118            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID =
119                    new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
120                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, MDRRuleImpl.class,
121                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRuleGroupId",
122                            new String[] { Long.class.getName() },
123                            MDRRuleModelImpl.RULEGROUPID_COLUMN_BITMASK);
124            public static final FinderPath FINDER_PATH_COUNT_BY_RULEGROUPID = new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
125                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, Long.class,
126                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRuleGroupId",
127                            new String[] { Long.class.getName() });
128            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
129                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, MDRRuleImpl.class,
130                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
131            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
132                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, MDRRuleImpl.class,
133                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
134            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
135                            MDRRuleModelImpl.FINDER_CACHE_ENABLED, Long.class,
136                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
137    
138            /**
139             * Caches the m d r rule in the entity cache if it is enabled.
140             *
141             * @param mdrRule the m d r rule
142             */
143            public void cacheResult(MDRRule mdrRule) {
144                    EntityCacheUtil.putResult(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
145                            MDRRuleImpl.class, mdrRule.getPrimaryKey(), mdrRule);
146    
147                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
148                            new Object[] { mdrRule.getUuid(), Long.valueOf(mdrRule.getGroupId()) },
149                            mdrRule);
150    
151                    mdrRule.resetOriginalValues();
152            }
153    
154            /**
155             * Caches the m d r rules in the entity cache if it is enabled.
156             *
157             * @param mdrRules the m d r rules
158             */
159            public void cacheResult(List<MDRRule> mdrRules) {
160                    for (MDRRule mdrRule : mdrRules) {
161                            if (EntityCacheUtil.getResult(
162                                                    MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
163                                                    MDRRuleImpl.class, mdrRule.getPrimaryKey()) == null) {
164                                    cacheResult(mdrRule);
165                            }
166                            else {
167                                    mdrRule.resetOriginalValues();
168                            }
169                    }
170            }
171    
172            /**
173             * Clears the cache for all m d r rules.
174             *
175             * <p>
176             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
177             * </p>
178             */
179            @Override
180            public void clearCache() {
181                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
182                            CacheRegistryUtil.clear(MDRRuleImpl.class.getName());
183                    }
184    
185                    EntityCacheUtil.clearCache(MDRRuleImpl.class.getName());
186    
187                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
188                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
189                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
190            }
191    
192            /**
193             * Clears the cache for the m d r rule.
194             *
195             * <p>
196             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
197             * </p>
198             */
199            @Override
200            public void clearCache(MDRRule mdrRule) {
201                    EntityCacheUtil.removeResult(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
202                            MDRRuleImpl.class, mdrRule.getPrimaryKey());
203    
204                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
205                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
206    
207                    clearUniqueFindersCache(mdrRule);
208            }
209    
210            @Override
211            public void clearCache(List<MDRRule> mdrRules) {
212                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
213                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
214    
215                    for (MDRRule mdrRule : mdrRules) {
216                            EntityCacheUtil.removeResult(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
217                                    MDRRuleImpl.class, mdrRule.getPrimaryKey());
218    
219                            clearUniqueFindersCache(mdrRule);
220                    }
221            }
222    
223            protected void clearUniqueFindersCache(MDRRule mdrRule) {
224                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
225                            new Object[] { mdrRule.getUuid(), Long.valueOf(mdrRule.getGroupId()) });
226            }
227    
228            /**
229             * Creates a new m d r rule with the primary key. Does not add the m d r rule to the database.
230             *
231             * @param ruleId the primary key for the new m d r rule
232             * @return the new m d r rule
233             */
234            public MDRRule create(long ruleId) {
235                    MDRRule mdrRule = new MDRRuleImpl();
236    
237                    mdrRule.setNew(true);
238                    mdrRule.setPrimaryKey(ruleId);
239    
240                    String uuid = PortalUUIDUtil.generate();
241    
242                    mdrRule.setUuid(uuid);
243    
244                    return mdrRule;
245            }
246    
247            /**
248             * Removes the m d r rule with the primary key from the database. Also notifies the appropriate model listeners.
249             *
250             * @param ruleId the primary key of the m d r rule
251             * @return the m d r rule that was removed
252             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleException if a m d r rule with the primary key could not be found
253             * @throws SystemException if a system exception occurred
254             */
255            public MDRRule remove(long ruleId)
256                    throws NoSuchRuleException, SystemException {
257                    return remove(Long.valueOf(ruleId));
258            }
259    
260            /**
261             * Removes the m d r rule with the primary key from the database. Also notifies the appropriate model listeners.
262             *
263             * @param primaryKey the primary key of the m d r rule
264             * @return the m d r rule that was removed
265             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleException if a m d r rule with the primary key could not be found
266             * @throws SystemException if a system exception occurred
267             */
268            @Override
269            public MDRRule remove(Serializable primaryKey)
270                    throws NoSuchRuleException, SystemException {
271                    Session session = null;
272    
273                    try {
274                            session = openSession();
275    
276                            MDRRule mdrRule = (MDRRule)session.get(MDRRuleImpl.class, primaryKey);
277    
278                            if (mdrRule == null) {
279                                    if (_log.isWarnEnabled()) {
280                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
281                                    }
282    
283                                    throw new NoSuchRuleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
284                                            primaryKey);
285                            }
286    
287                            return remove(mdrRule);
288                    }
289                    catch (NoSuchRuleException nsee) {
290                            throw nsee;
291                    }
292                    catch (Exception e) {
293                            throw processException(e);
294                    }
295                    finally {
296                            closeSession(session);
297                    }
298            }
299    
300            @Override
301            protected MDRRule removeImpl(MDRRule mdrRule) throws SystemException {
302                    mdrRule = toUnwrappedModel(mdrRule);
303    
304                    Session session = null;
305    
306                    try {
307                            session = openSession();
308    
309                            BatchSessionUtil.delete(session, mdrRule);
310                    }
311                    catch (Exception e) {
312                            throw processException(e);
313                    }
314                    finally {
315                            closeSession(session);
316                    }
317    
318                    clearCache(mdrRule);
319    
320                    return mdrRule;
321            }
322    
323            @Override
324            public MDRRule updateImpl(
325                    com.liferay.portlet.mobiledevicerules.model.MDRRule mdrRule,
326                    boolean merge) throws SystemException {
327                    mdrRule = toUnwrappedModel(mdrRule);
328    
329                    boolean isNew = mdrRule.isNew();
330    
331                    MDRRuleModelImpl mdrRuleModelImpl = (MDRRuleModelImpl)mdrRule;
332    
333                    if (Validator.isNull(mdrRule.getUuid())) {
334                            String uuid = PortalUUIDUtil.generate();
335    
336                            mdrRule.setUuid(uuid);
337                    }
338    
339                    Session session = null;
340    
341                    try {
342                            session = openSession();
343    
344                            BatchSessionUtil.update(session, mdrRule, merge);
345    
346                            mdrRule.setNew(false);
347                    }
348                    catch (Exception e) {
349                            throw processException(e);
350                    }
351                    finally {
352                            closeSession(session);
353                    }
354    
355                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
356    
357                    if (isNew || !MDRRuleModelImpl.COLUMN_BITMASK_ENABLED) {
358                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
359                    }
360    
361                    else {
362                            if ((mdrRuleModelImpl.getColumnBitmask() &
363                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
364                                    Object[] args = new Object[] { mdrRuleModelImpl.getOriginalUuid() };
365    
366                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
367                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
368                                            args);
369    
370                                    args = new Object[] { mdrRuleModelImpl.getUuid() };
371    
372                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
373                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
374                                            args);
375                            }
376    
377                            if ((mdrRuleModelImpl.getColumnBitmask() &
378                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID.getColumnBitmask()) != 0) {
379                                    Object[] args = new Object[] {
380                                                    Long.valueOf(mdrRuleModelImpl.getOriginalRuleGroupId())
381                                            };
382    
383                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
384                                            args);
385                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID,
386                                            args);
387    
388                                    args = new Object[] {
389                                                    Long.valueOf(mdrRuleModelImpl.getRuleGroupId())
390                                            };
391    
392                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
393                                            args);
394                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID,
395                                            args);
396                            }
397                    }
398    
399                    EntityCacheUtil.putResult(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
400                            MDRRuleImpl.class, mdrRule.getPrimaryKey(), mdrRule);
401    
402                    if (isNew) {
403                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
404                                    new Object[] {
405                                            mdrRule.getUuid(), Long.valueOf(mdrRule.getGroupId())
406                                    }, mdrRule);
407                    }
408                    else {
409                            if ((mdrRuleModelImpl.getColumnBitmask() &
410                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
411                                    Object[] args = new Object[] {
412                                                    mdrRuleModelImpl.getOriginalUuid(),
413                                                    Long.valueOf(mdrRuleModelImpl.getOriginalGroupId())
414                                            };
415    
416                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
417                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
418    
419                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
420                                            new Object[] {
421                                                    mdrRule.getUuid(), Long.valueOf(mdrRule.getGroupId())
422                                            }, mdrRule);
423                            }
424                    }
425    
426                    return mdrRule;
427            }
428    
429            protected MDRRule toUnwrappedModel(MDRRule mdrRule) {
430                    if (mdrRule instanceof MDRRuleImpl) {
431                            return mdrRule;
432                    }
433    
434                    MDRRuleImpl mdrRuleImpl = new MDRRuleImpl();
435    
436                    mdrRuleImpl.setNew(mdrRule.isNew());
437                    mdrRuleImpl.setPrimaryKey(mdrRule.getPrimaryKey());
438    
439                    mdrRuleImpl.setUuid(mdrRule.getUuid());
440                    mdrRuleImpl.setRuleId(mdrRule.getRuleId());
441                    mdrRuleImpl.setGroupId(mdrRule.getGroupId());
442                    mdrRuleImpl.setCompanyId(mdrRule.getCompanyId());
443                    mdrRuleImpl.setUserId(mdrRule.getUserId());
444                    mdrRuleImpl.setUserName(mdrRule.getUserName());
445                    mdrRuleImpl.setCreateDate(mdrRule.getCreateDate());
446                    mdrRuleImpl.setModifiedDate(mdrRule.getModifiedDate());
447                    mdrRuleImpl.setRuleGroupId(mdrRule.getRuleGroupId());
448                    mdrRuleImpl.setName(mdrRule.getName());
449                    mdrRuleImpl.setDescription(mdrRule.getDescription());
450                    mdrRuleImpl.setType(mdrRule.getType());
451                    mdrRuleImpl.setTypeSettings(mdrRule.getTypeSettings());
452    
453                    return mdrRuleImpl;
454            }
455    
456            /**
457             * Returns the m d r rule with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
458             *
459             * @param primaryKey the primary key of the m d r rule
460             * @return the m d r rule
461             * @throws com.liferay.portal.NoSuchModelException if a m d r rule with the primary key could not be found
462             * @throws SystemException if a system exception occurred
463             */
464            @Override
465            public MDRRule findByPrimaryKey(Serializable primaryKey)
466                    throws NoSuchModelException, SystemException {
467                    return findByPrimaryKey(((Long)primaryKey).longValue());
468            }
469    
470            /**
471             * Returns the m d r rule with the primary key or throws a {@link com.liferay.portlet.mobiledevicerules.NoSuchRuleException} if it could not be found.
472             *
473             * @param ruleId the primary key of the m d r rule
474             * @return the m d r rule
475             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleException if a m d r rule with the primary key could not be found
476             * @throws SystemException if a system exception occurred
477             */
478            public MDRRule findByPrimaryKey(long ruleId)
479                    throws NoSuchRuleException, SystemException {
480                    MDRRule mdrRule = fetchByPrimaryKey(ruleId);
481    
482                    if (mdrRule == null) {
483                            if (_log.isWarnEnabled()) {
484                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + ruleId);
485                            }
486    
487                            throw new NoSuchRuleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
488                                    ruleId);
489                    }
490    
491                    return mdrRule;
492            }
493    
494            /**
495             * Returns the m d r rule with the primary key or returns <code>null</code> if it could not be found.
496             *
497             * @param primaryKey the primary key of the m d r rule
498             * @return the m d r rule, or <code>null</code> if a m d r rule with the primary key could not be found
499             * @throws SystemException if a system exception occurred
500             */
501            @Override
502            public MDRRule fetchByPrimaryKey(Serializable primaryKey)
503                    throws SystemException {
504                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
505            }
506    
507            /**
508             * Returns the m d r rule with the primary key or returns <code>null</code> if it could not be found.
509             *
510             * @param ruleId the primary key of the m d r rule
511             * @return the m d r rule, or <code>null</code> if a m d r rule with the primary key could not be found
512             * @throws SystemException if a system exception occurred
513             */
514            public MDRRule fetchByPrimaryKey(long ruleId) throws SystemException {
515                    MDRRule mdrRule = (MDRRule)EntityCacheUtil.getResult(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
516                                    MDRRuleImpl.class, ruleId);
517    
518                    if (mdrRule == _nullMDRRule) {
519                            return null;
520                    }
521    
522                    if (mdrRule == null) {
523                            Session session = null;
524    
525                            boolean hasException = false;
526    
527                            try {
528                                    session = openSession();
529    
530                                    mdrRule = (MDRRule)session.get(MDRRuleImpl.class,
531                                                    Long.valueOf(ruleId));
532                            }
533                            catch (Exception e) {
534                                    hasException = true;
535    
536                                    throw processException(e);
537                            }
538                            finally {
539                                    if (mdrRule != null) {
540                                            cacheResult(mdrRule);
541                                    }
542                                    else if (!hasException) {
543                                            EntityCacheUtil.putResult(MDRRuleModelImpl.ENTITY_CACHE_ENABLED,
544                                                    MDRRuleImpl.class, ruleId, _nullMDRRule);
545                                    }
546    
547                                    closeSession(session);
548                            }
549                    }
550    
551                    return mdrRule;
552            }
553    
554            /**
555             * Returns all the m d r rules where uuid = &#63;.
556             *
557             * @param uuid the uuid
558             * @return the matching m d r rules
559             * @throws SystemException if a system exception occurred
560             */
561            public List<MDRRule> findByUuid(String uuid) throws SystemException {
562                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
563            }
564    
565            /**
566             * Returns a range of all the m d r rules where uuid = &#63;.
567             *
568             * <p>
569             * 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.
570             * </p>
571             *
572             * @param uuid the uuid
573             * @param start the lower bound of the range of m d r rules
574             * @param end the upper bound of the range of m d r rules (not inclusive)
575             * @return the range of matching m d r rules
576             * @throws SystemException if a system exception occurred
577             */
578            public List<MDRRule> findByUuid(String uuid, int start, int end)
579                    throws SystemException {
580                    return findByUuid(uuid, start, end, null);
581            }
582    
583            /**
584             * Returns an ordered range of all the m d r rules where uuid = &#63;.
585             *
586             * <p>
587             * 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.
588             * </p>
589             *
590             * @param uuid the uuid
591             * @param start the lower bound of the range of m d r rules
592             * @param end the upper bound of the range of m d r rules (not inclusive)
593             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
594             * @return the ordered range of matching m d r rules
595             * @throws SystemException if a system exception occurred
596             */
597            public List<MDRRule> findByUuid(String uuid, int start, int end,
598                    OrderByComparator orderByComparator) throws SystemException {
599                    FinderPath finderPath = null;
600                    Object[] finderArgs = null;
601    
602                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
603                                    (orderByComparator == null)) {
604                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
605                            finderArgs = new Object[] { uuid };
606                    }
607                    else {
608                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
609                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
610                    }
611    
612                    List<MDRRule> list = (List<MDRRule>)FinderCacheUtil.getResult(finderPath,
613                                    finderArgs, this);
614    
615                    if (list == null) {
616                            StringBundler query = null;
617    
618                            if (orderByComparator != null) {
619                                    query = new StringBundler(3 +
620                                                    (orderByComparator.getOrderByFields().length * 3));
621                            }
622                            else {
623                                    query = new StringBundler(2);
624                            }
625    
626                            query.append(_SQL_SELECT_MDRRULE_WHERE);
627    
628                            if (uuid == null) {
629                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
630                            }
631                            else {
632                                    if (uuid.equals(StringPool.BLANK)) {
633                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
634                                    }
635                                    else {
636                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
637                                    }
638                            }
639    
640                            if (orderByComparator != null) {
641                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
642                                            orderByComparator);
643                            }
644    
645                            String sql = query.toString();
646    
647                            Session session = null;
648    
649                            try {
650                                    session = openSession();
651    
652                                    Query q = session.createQuery(sql);
653    
654                                    QueryPos qPos = QueryPos.getInstance(q);
655    
656                                    if (uuid != null) {
657                                            qPos.add(uuid);
658                                    }
659    
660                                    list = (List<MDRRule>)QueryUtil.list(q, getDialect(), start, end);
661                            }
662                            catch (Exception e) {
663                                    throw processException(e);
664                            }
665                            finally {
666                                    if (list == null) {
667                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
668                                    }
669                                    else {
670                                            cacheResult(list);
671    
672                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
673                                    }
674    
675                                    closeSession(session);
676                            }
677                    }
678    
679                    return list;
680            }
681    
682            /**
683             * Returns the first m d r rule in the ordered set where uuid = &#63;.
684             *
685             * <p>
686             * 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.
687             * </p>
688             *
689             * @param uuid the uuid
690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
691             * @return the first matching m d r rule
692             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleException if a matching m d r rule could not be found
693             * @throws SystemException if a system exception occurred
694             */
695            public MDRRule findByUuid_First(String uuid,
696                    OrderByComparator orderByComparator)
697                    throws NoSuchRuleException, SystemException {
698                    List<MDRRule> list = findByUuid(uuid, 0, 1, orderByComparator);
699    
700                    if (list.isEmpty()) {
701                            StringBundler msg = new StringBundler(4);
702    
703                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
704    
705                            msg.append("uuid=");
706                            msg.append(uuid);
707    
708                            msg.append(StringPool.CLOSE_CURLY_BRACE);
709    
710                            throw new NoSuchRuleException(msg.toString());
711                    }
712                    else {
713                            return list.get(0);
714                    }
715            }
716    
717            /**
718             * Returns the last m d r rule in the ordered set where uuid = &#63;.
719             *
720             * <p>
721             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
722             * </p>
723             *
724             * @param uuid the uuid
725             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
726             * @return the last matching m d r rule
727             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleException if a matching m d r rule could not be found
728             * @throws SystemException if a system exception occurred
729             */
730            public MDRRule findByUuid_Last(String uuid,
731                    OrderByComparator orderByComparator)
732                    throws NoSuchRuleException, SystemException {
733                    int count = countByUuid(uuid);
734    
735                    List<MDRRule> list = findByUuid(uuid, count - 1, count,
736                                    orderByComparator);
737    
738                    if (list.isEmpty()) {
739                            StringBundler msg = new StringBundler(4);
740    
741                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
742    
743                            msg.append("uuid=");
744                            msg.append(uuid);
745    
746                            msg.append(StringPool.CLOSE_CURLY_BRACE);
747    
748                            throw new NoSuchRuleException(msg.toString());
749                    }
750                    else {
751                            return list.get(0);
752                    }
753            }
754    
755            /**
756             * Returns the m d r rules before and after the current m d r rule in the ordered set where uuid = &#63;.
757             *
758             * <p>
759             * 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.
760             * </p>
761             *
762             * @param ruleId the primary key of the current m d r rule
763             * @param uuid the uuid
764             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
765             * @return the previous, current, and next m d r rule
766             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleException if a m d r rule with the primary key could not be found
767             * @throws SystemException if a system exception occurred
768             */
769            public MDRRule[] findByUuid_PrevAndNext(long ruleId, String uuid,
770                    OrderByComparator orderByComparator)
771                    throws NoSuchRuleException, SystemException {
772                    MDRRule mdrRule = findByPrimaryKey(ruleId);
773    
774                    Session session = null;
775    
776                    try {
777                            session = openSession();
778    
779                            MDRRule[] array = new MDRRuleImpl[3];
780    
781                            array[0] = getByUuid_PrevAndNext(session, mdrRule, uuid,
782                                            orderByComparator, true);
783    
784                            array[1] = mdrRule;
785    
786                            array[2] = getByUuid_PrevAndNext(session, mdrRule, uuid,
787                                            orderByComparator, false);
788    
789                            return array;
790                    }
791                    catch (Exception e) {
792                            throw processException(e);
793                    }
794                    finally {
795                            closeSession(session);
796                    }
797            }
798    
799            protected MDRRule getByUuid_PrevAndNext(Session session, MDRRule mdrRule,
800                    String uuid, OrderByComparator orderByComparator, boolean previous) {
801                    StringBundler query = null;
802    
803                    if (orderByComparator != null) {
804                            query = new StringBundler(6 +
805                                            (orderByComparator.getOrderByFields().length * 6));
806                    }
807                    else {
808                            query = new StringBundler(3);
809                    }
810    
811                    query.append(_SQL_SELECT_MDRRULE_WHERE);
812    
813                    if (uuid == null) {
814                            query.append(_FINDER_COLUMN_UUID_UUID_1);
815                    }
816                    else {
817                            if (uuid.equals(StringPool.BLANK)) {
818                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
819                            }
820                            else {
821                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
822                            }
823                    }
824    
825                    if (orderByComparator != null) {
826                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
827    
828                            if (orderByConditionFields.length > 0) {
829                                    query.append(WHERE_AND);
830                            }
831    
832                            for (int i = 0; i < orderByConditionFields.length; i++) {
833                                    query.append(_ORDER_BY_ENTITY_ALIAS);
834                                    query.append(orderByConditionFields[i]);
835    
836                                    if ((i + 1) < orderByConditionFields.length) {
837                                            if (orderByComparator.isAscending() ^ previous) {
838                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
839                                            }
840                                            else {
841                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
842                                            }
843                                    }
844                                    else {
845                                            if (orderByComparator.isAscending() ^ previous) {
846                                                    query.append(WHERE_GREATER_THAN);
847                                            }
848                                            else {
849                                                    query.append(WHERE_LESSER_THAN);
850                                            }
851                                    }
852                            }
853    
854                            query.append(ORDER_BY_CLAUSE);
855    
856                            String[] orderByFields = orderByComparator.getOrderByFields();
857    
858                            for (int i = 0; i < orderByFields.length; i++) {
859                                    query.append(_ORDER_BY_ENTITY_ALIAS);
860                                    query.append(orderByFields[i]);
861    
862                                    if ((i + 1) < orderByFields.length) {
863                                            if (orderByComparator.isAscending() ^ previous) {
864                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
865                                            }
866                                            else {
867                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
868                                            }
869                                    }
870                                    else {
871                                            if (orderByComparator.isAscending() ^ previous) {
872                                                    query.append(ORDER_BY_ASC);
873                                            }
874                                            else {
875                                                    query.append(ORDER_BY_DESC);
876                                            }
877                                    }
878                            }
879                    }
880    
881                    String sql = query.toString();
882    
883                    Query q = session.createQuery(sql);
884    
885                    q.setFirstResult(0);
886                    q.setMaxResults(2);
887    
888                    QueryPos qPos = QueryPos.getInstance(q);
889    
890                    if (uuid != null) {
891                            qPos.add(uuid);
892                    }
893    
894                    if (orderByComparator != null) {
895                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRule);
896    
897                            for (Object value : values) {
898                                    qPos.add(value);
899                            }
900                    }
901    
902                    List<MDRRule> list = q.list();
903    
904                    if (list.size() == 2) {
905                            return list.get(1);
906                    }
907                    else {
908                            return null;
909                    }
910            }
911    
912            /**
913             * Returns the m d r rule where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.mobiledevicerules.NoSuchRuleException} if it could not be found.
914             *
915             * @param uuid the uuid
916             * @param groupId the group ID
917             * @return the matching m d r rule
918             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleException if a matching m d r rule could not be found
919             * @throws SystemException if a system exception occurred
920             */
921            public MDRRule findByUUID_G(String uuid, long groupId)
922                    throws NoSuchRuleException, SystemException {
923                    MDRRule mdrRule = fetchByUUID_G(uuid, groupId);
924    
925                    if (mdrRule == null) {
926                            StringBundler msg = new StringBundler(6);
927    
928                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
929    
930                            msg.append("uuid=");
931                            msg.append(uuid);
932    
933                            msg.append(", groupId=");
934                            msg.append(groupId);
935    
936                            msg.append(StringPool.CLOSE_CURLY_BRACE);
937    
938                            if (_log.isWarnEnabled()) {
939                                    _log.warn(msg.toString());
940                            }
941    
942                            throw new NoSuchRuleException(msg.toString());
943                    }
944    
945                    return mdrRule;
946            }
947    
948            /**
949             * Returns the m d r rule where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
950             *
951             * @param uuid the uuid
952             * @param groupId the group ID
953             * @return the matching m d r rule, or <code>null</code> if a matching m d r rule could not be found
954             * @throws SystemException if a system exception occurred
955             */
956            public MDRRule fetchByUUID_G(String uuid, long groupId)
957                    throws SystemException {
958                    return fetchByUUID_G(uuid, groupId, true);
959            }
960    
961            /**
962             * Returns the m d r rule where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
963             *
964             * @param uuid the uuid
965             * @param groupId the group ID
966             * @param retrieveFromCache whether to use the finder cache
967             * @return the matching m d r rule, or <code>null</code> if a matching m d r rule could not be found
968             * @throws SystemException if a system exception occurred
969             */
970            public MDRRule fetchByUUID_G(String uuid, long groupId,
971                    boolean retrieveFromCache) throws SystemException {
972                    Object[] finderArgs = new Object[] { uuid, groupId };
973    
974                    Object result = null;
975    
976                    if (retrieveFromCache) {
977                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
978                                            finderArgs, this);
979                    }
980    
981                    if (result == null) {
982                            StringBundler query = new StringBundler(3);
983    
984                            query.append(_SQL_SELECT_MDRRULE_WHERE);
985    
986                            if (uuid == null) {
987                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
988                            }
989                            else {
990                                    if (uuid.equals(StringPool.BLANK)) {
991                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
992                                    }
993                                    else {
994                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
995                                    }
996                            }
997    
998                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
999    
1000                            String sql = query.toString();
1001    
1002                            Session session = null;
1003    
1004                            try {
1005                                    session = openSession();
1006    
1007                                    Query q = session.createQuery(sql);
1008    
1009                                    QueryPos qPos = QueryPos.getInstance(q);
1010    
1011                                    if (uuid != null) {
1012                                            qPos.add(uuid);
1013                                    }
1014    
1015                                    qPos.add(groupId);
1016    
1017                                    List<MDRRule> list = q.list();
1018    
1019                                    result = list;
1020    
1021                                    MDRRule mdrRule = null;
1022    
1023                                    if (list.isEmpty()) {
1024                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1025                                                    finderArgs, list);
1026                                    }
1027                                    else {
1028                                            mdrRule = list.get(0);
1029    
1030                                            cacheResult(mdrRule);
1031    
1032                                            if ((mdrRule.getUuid() == null) ||
1033                                                            !mdrRule.getUuid().equals(uuid) ||
1034                                                            (mdrRule.getGroupId() != groupId)) {
1035                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1036                                                            finderArgs, mdrRule);
1037                                            }
1038                                    }
1039    
1040                                    return mdrRule;
1041                            }
1042                            catch (Exception e) {
1043                                    throw processException(e);
1044                            }
1045                            finally {
1046                                    if (result == null) {
1047                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1048                                                    finderArgs);
1049                                    }
1050    
1051                                    closeSession(session);
1052                            }
1053                    }
1054                    else {
1055                            if (result instanceof List<?>) {
1056                                    return null;
1057                            }
1058                            else {
1059                                    return (MDRRule)result;
1060                            }
1061                    }
1062            }
1063    
1064            /**
1065             * Returns all the m d r rules where ruleGroupId = &#63;.
1066             *
1067             * @param ruleGroupId the rule group ID
1068             * @return the matching m d r rules
1069             * @throws SystemException if a system exception occurred
1070             */
1071            public List<MDRRule> findByRuleGroupId(long ruleGroupId)
1072                    throws SystemException {
1073                    return findByRuleGroupId(ruleGroupId, QueryUtil.ALL_POS,
1074                            QueryUtil.ALL_POS, null);
1075            }
1076    
1077            /**
1078             * Returns a range of all the m d r rules where ruleGroupId = &#63;.
1079             *
1080             * <p>
1081             * 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.
1082             * </p>
1083             *
1084             * @param ruleGroupId the rule group ID
1085             * @param start the lower bound of the range of m d r rules
1086             * @param end the upper bound of the range of m d r rules (not inclusive)
1087             * @return the range of matching m d r rules
1088             * @throws SystemException if a system exception occurred
1089             */
1090            public List<MDRRule> findByRuleGroupId(long ruleGroupId, int start, int end)
1091                    throws SystemException {
1092                    return findByRuleGroupId(ruleGroupId, start, end, null);
1093            }
1094    
1095            /**
1096             * Returns an ordered range of all the m d r rules where ruleGroupId = &#63;.
1097             *
1098             * <p>
1099             * 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.
1100             * </p>
1101             *
1102             * @param ruleGroupId the rule group ID
1103             * @param start the lower bound of the range of m d r rules
1104             * @param end the upper bound of the range of m d r rules (not inclusive)
1105             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1106             * @return the ordered range of matching m d r rules
1107             * @throws SystemException if a system exception occurred
1108             */
1109            public List<MDRRule> findByRuleGroupId(long ruleGroupId, int start,
1110                    int end, OrderByComparator orderByComparator) throws SystemException {
1111                    FinderPath finderPath = null;
1112                    Object[] finderArgs = null;
1113    
1114                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1115                                    (orderByComparator == null)) {
1116                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID;
1117                            finderArgs = new Object[] { ruleGroupId };
1118                    }
1119                    else {
1120                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPID;
1121                            finderArgs = new Object[] { ruleGroupId, start, end, orderByComparator };
1122                    }
1123    
1124                    List<MDRRule> list = (List<MDRRule>)FinderCacheUtil.getResult(finderPath,
1125                                    finderArgs, this);
1126    
1127                    if (list == null) {
1128                            StringBundler query = null;
1129    
1130                            if (orderByComparator != null) {
1131                                    query = new StringBundler(3 +
1132                                                    (orderByComparator.getOrderByFields().length * 3));
1133                            }
1134                            else {
1135                                    query = new StringBundler(2);
1136                            }
1137    
1138                            query.append(_SQL_SELECT_MDRRULE_WHERE);
1139    
1140                            query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
1141    
1142                            if (orderByComparator != null) {
1143                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1144                                            orderByComparator);
1145                            }
1146    
1147                            String sql = query.toString();
1148    
1149                            Session session = null;
1150    
1151                            try {
1152                                    session = openSession();
1153    
1154                                    Query q = session.createQuery(sql);
1155    
1156                                    QueryPos qPos = QueryPos.getInstance(q);
1157    
1158                                    qPos.add(ruleGroupId);
1159    
1160                                    list = (List<MDRRule>)QueryUtil.list(q, getDialect(), start, end);
1161                            }
1162                            catch (Exception e) {
1163                                    throw processException(e);
1164                            }
1165                            finally {
1166                                    if (list == null) {
1167                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1168                                    }
1169                                    else {
1170                                            cacheResult(list);
1171    
1172                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1173                                    }
1174    
1175                                    closeSession(session);
1176                            }
1177                    }
1178    
1179                    return list;
1180            }
1181    
1182            /**
1183             * Returns the first m d r rule in the ordered set where ruleGroupId = &#63;.
1184             *
1185             * <p>
1186             * 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.
1187             * </p>
1188             *
1189             * @param ruleGroupId the rule group ID
1190             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1191             * @return the first matching m d r rule
1192             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleException if a matching m d r rule could not be found
1193             * @throws SystemException if a system exception occurred
1194             */
1195            public MDRRule findByRuleGroupId_First(long ruleGroupId,
1196                    OrderByComparator orderByComparator)
1197                    throws NoSuchRuleException, SystemException {
1198                    List<MDRRule> list = findByRuleGroupId(ruleGroupId, 0, 1,
1199                                    orderByComparator);
1200    
1201                    if (list.isEmpty()) {
1202                            StringBundler msg = new StringBundler(4);
1203    
1204                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1205    
1206                            msg.append("ruleGroupId=");
1207                            msg.append(ruleGroupId);
1208    
1209                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1210    
1211                            throw new NoSuchRuleException(msg.toString());
1212                    }
1213                    else {
1214                            return list.get(0);
1215                    }
1216            }
1217    
1218            /**
1219             * Returns the last m d r rule in the ordered set where ruleGroupId = &#63;.
1220             *
1221             * <p>
1222             * 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.
1223             * </p>
1224             *
1225             * @param ruleGroupId the rule group ID
1226             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1227             * @return the last matching m d r rule
1228             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleException if a matching m d r rule could not be found
1229             * @throws SystemException if a system exception occurred
1230             */
1231            public MDRRule findByRuleGroupId_Last(long ruleGroupId,
1232                    OrderByComparator orderByComparator)
1233                    throws NoSuchRuleException, SystemException {
1234                    int count = countByRuleGroupId(ruleGroupId);
1235    
1236                    List<MDRRule> list = findByRuleGroupId(ruleGroupId, count - 1, count,
1237                                    orderByComparator);
1238    
1239                    if (list.isEmpty()) {
1240                            StringBundler msg = new StringBundler(4);
1241    
1242                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1243    
1244                            msg.append("ruleGroupId=");
1245                            msg.append(ruleGroupId);
1246    
1247                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1248    
1249                            throw new NoSuchRuleException(msg.toString());
1250                    }
1251                    else {
1252                            return list.get(0);
1253                    }
1254            }
1255    
1256            /**
1257             * Returns the m d r rules before and after the current m d r rule in the ordered set where ruleGroupId = &#63;.
1258             *
1259             * <p>
1260             * 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.
1261             * </p>
1262             *
1263             * @param ruleId the primary key of the current m d r rule
1264             * @param ruleGroupId the rule group ID
1265             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1266             * @return the previous, current, and next m d r rule
1267             * @throws com.liferay.portlet.mobiledevicerules.NoSuchRuleException if a m d r rule with the primary key could not be found
1268             * @throws SystemException if a system exception occurred
1269             */
1270            public MDRRule[] findByRuleGroupId_PrevAndNext(long ruleId,
1271                    long ruleGroupId, OrderByComparator orderByComparator)
1272                    throws NoSuchRuleException, SystemException {
1273                    MDRRule mdrRule = findByPrimaryKey(ruleId);
1274    
1275                    Session session = null;
1276    
1277                    try {
1278                            session = openSession();
1279    
1280                            MDRRule[] array = new MDRRuleImpl[3];
1281    
1282                            array[0] = getByRuleGroupId_PrevAndNext(session, mdrRule,
1283                                            ruleGroupId, orderByComparator, true);
1284    
1285                            array[1] = mdrRule;
1286    
1287                            array[2] = getByRuleGroupId_PrevAndNext(session, mdrRule,
1288                                            ruleGroupId, orderByComparator, false);
1289    
1290                            return array;
1291                    }
1292                    catch (Exception e) {
1293                            throw processException(e);
1294                    }
1295                    finally {
1296                            closeSession(session);
1297                    }
1298            }
1299    
1300            protected MDRRule getByRuleGroupId_PrevAndNext(Session session,
1301                    MDRRule mdrRule, long ruleGroupId, OrderByComparator orderByComparator,
1302                    boolean previous) {
1303                    StringBundler query = null;
1304    
1305                    if (orderByComparator != null) {
1306                            query = new StringBundler(6 +
1307                                            (orderByComparator.getOrderByFields().length * 6));
1308                    }
1309                    else {
1310                            query = new StringBundler(3);
1311                    }
1312    
1313                    query.append(_SQL_SELECT_MDRRULE_WHERE);
1314    
1315                    query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
1316    
1317                    if (orderByComparator != null) {
1318                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1319    
1320                            if (orderByConditionFields.length > 0) {
1321                                    query.append(WHERE_AND);
1322                            }
1323    
1324                            for (int i = 0; i < orderByConditionFields.length; i++) {
1325                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1326                                    query.append(orderByConditionFields[i]);
1327    
1328                                    if ((i + 1) < orderByConditionFields.length) {
1329                                            if (orderByComparator.isAscending() ^ previous) {
1330                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1331                                            }
1332                                            else {
1333                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1334                                            }
1335                                    }
1336                                    else {
1337                                            if (orderByComparator.isAscending() ^ previous) {
1338                                                    query.append(WHERE_GREATER_THAN);
1339                                            }
1340                                            else {
1341                                                    query.append(WHERE_LESSER_THAN);
1342                                            }
1343                                    }
1344                            }
1345    
1346                            query.append(ORDER_BY_CLAUSE);
1347    
1348                            String[] orderByFields = orderByComparator.getOrderByFields();
1349    
1350                            for (int i = 0; i < orderByFields.length; i++) {
1351                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1352                                    query.append(orderByFields[i]);
1353    
1354                                    if ((i + 1) < orderByFields.length) {
1355                                            if (orderByComparator.isAscending() ^ previous) {
1356                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1357                                            }
1358                                            else {
1359                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1360                                            }
1361                                    }
1362                                    else {
1363                                            if (orderByComparator.isAscending() ^ previous) {
1364                                                    query.append(ORDER_BY_ASC);
1365                                            }
1366                                            else {
1367                                                    query.append(ORDER_BY_DESC);
1368                                            }
1369                                    }
1370                            }
1371                    }
1372    
1373                    String sql = query.toString();
1374    
1375                    Query q = session.createQuery(sql);
1376    
1377                    q.setFirstResult(0);
1378                    q.setMaxResults(2);
1379    
1380                    QueryPos qPos = QueryPos.getInstance(q);
1381    
1382                    qPos.add(ruleGroupId);
1383    
1384                    if (orderByComparator != null) {
1385                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRule);
1386    
1387                            for (Object value : values) {
1388                                    qPos.add(value);
1389                            }
1390                    }
1391    
1392                    List<MDRRule> list = q.list();
1393    
1394                    if (list.size() == 2) {
1395                            return list.get(1);
1396                    }
1397                    else {
1398                            return null;
1399                    }
1400            }
1401    
1402            /**
1403             * Returns all the m d r rules.
1404             *
1405             * @return the m d r rules
1406             * @throws SystemException if a system exception occurred
1407             */
1408            public List<MDRRule> findAll() throws SystemException {
1409                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1410            }
1411    
1412            /**
1413             * Returns a range of all the m d r rules.
1414             *
1415             * <p>
1416             * 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.
1417             * </p>
1418             *
1419             * @param start the lower bound of the range of m d r rules
1420             * @param end the upper bound of the range of m d r rules (not inclusive)
1421             * @return the range of m d r rules
1422             * @throws SystemException if a system exception occurred
1423             */
1424            public List<MDRRule> findAll(int start, int end) throws SystemException {
1425                    return findAll(start, end, null);
1426            }
1427    
1428            /**
1429             * Returns an ordered range of all the m d r rules.
1430             *
1431             * <p>
1432             * 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.
1433             * </p>
1434             *
1435             * @param start the lower bound of the range of m d r rules
1436             * @param end the upper bound of the range of m d r rules (not inclusive)
1437             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1438             * @return the ordered range of m d r rules
1439             * @throws SystemException if a system exception occurred
1440             */
1441            public List<MDRRule> findAll(int start, int end,
1442                    OrderByComparator orderByComparator) throws SystemException {
1443                    FinderPath finderPath = null;
1444                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1445    
1446                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1447                                    (orderByComparator == null)) {
1448                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1449                            finderArgs = FINDER_ARGS_EMPTY;
1450                    }
1451                    else {
1452                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1453                            finderArgs = new Object[] { start, end, orderByComparator };
1454                    }
1455    
1456                    List<MDRRule> list = (List<MDRRule>)FinderCacheUtil.getResult(finderPath,
1457                                    finderArgs, this);
1458    
1459                    if (list == null) {
1460                            StringBundler query = null;
1461                            String sql = null;
1462    
1463                            if (orderByComparator != null) {
1464                                    query = new StringBundler(2 +
1465                                                    (orderByComparator.getOrderByFields().length * 3));
1466    
1467                                    query.append(_SQL_SELECT_MDRRULE);
1468    
1469                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1470                                            orderByComparator);
1471    
1472                                    sql = query.toString();
1473                            }
1474                            else {
1475                                    sql = _SQL_SELECT_MDRRULE;
1476                            }
1477    
1478                            Session session = null;
1479    
1480                            try {
1481                                    session = openSession();
1482    
1483                                    Query q = session.createQuery(sql);
1484    
1485                                    if (orderByComparator == null) {
1486                                            list = (List<MDRRule>)QueryUtil.list(q, getDialect(),
1487                                                            start, end, false);
1488    
1489                                            Collections.sort(list);
1490                                    }
1491                                    else {
1492                                            list = (List<MDRRule>)QueryUtil.list(q, getDialect(),
1493                                                            start, end);
1494                                    }
1495                            }
1496                            catch (Exception e) {
1497                                    throw processException(e);
1498                            }
1499                            finally {
1500                                    if (list == null) {
1501                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1502                                    }
1503                                    else {
1504                                            cacheResult(list);
1505    
1506                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1507                                    }
1508    
1509                                    closeSession(session);
1510                            }
1511                    }
1512    
1513                    return list;
1514            }
1515    
1516            /**
1517             * Removes all the m d r rules where uuid = &#63; from the database.
1518             *
1519             * @param uuid the uuid
1520             * @throws SystemException if a system exception occurred
1521             */
1522            public void removeByUuid(String uuid) throws SystemException {
1523                    for (MDRRule mdrRule : findByUuid(uuid)) {
1524                            remove(mdrRule);
1525                    }
1526            }
1527    
1528            /**
1529             * Removes the m d r rule where uuid = &#63; and groupId = &#63; from the database.
1530             *
1531             * @param uuid the uuid
1532             * @param groupId the group ID
1533             * @throws SystemException if a system exception occurred
1534             */
1535            public void removeByUUID_G(String uuid, long groupId)
1536                    throws NoSuchRuleException, SystemException {
1537                    MDRRule mdrRule = findByUUID_G(uuid, groupId);
1538    
1539                    remove(mdrRule);
1540            }
1541    
1542            /**
1543             * Removes all the m d r rules where ruleGroupId = &#63; from the database.
1544             *
1545             * @param ruleGroupId the rule group ID
1546             * @throws SystemException if a system exception occurred
1547             */
1548            public void removeByRuleGroupId(long ruleGroupId) throws SystemException {
1549                    for (MDRRule mdrRule : findByRuleGroupId(ruleGroupId)) {
1550                            remove(mdrRule);
1551                    }
1552            }
1553    
1554            /**
1555             * Removes all the m d r rules from the database.
1556             *
1557             * @throws SystemException if a system exception occurred
1558             */
1559            public void removeAll() throws SystemException {
1560                    for (MDRRule mdrRule : findAll()) {
1561                            remove(mdrRule);
1562                    }
1563            }
1564    
1565            /**
1566             * Returns the number of m d r rules where uuid = &#63;.
1567             *
1568             * @param uuid the uuid
1569             * @return the number of matching m d r rules
1570             * @throws SystemException if a system exception occurred
1571             */
1572            public int countByUuid(String uuid) throws SystemException {
1573                    Object[] finderArgs = new Object[] { uuid };
1574    
1575                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1576                                    finderArgs, this);
1577    
1578                    if (count == null) {
1579                            StringBundler query = new StringBundler(2);
1580    
1581                            query.append(_SQL_COUNT_MDRRULE_WHERE);
1582    
1583                            if (uuid == null) {
1584                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1585                            }
1586                            else {
1587                                    if (uuid.equals(StringPool.BLANK)) {
1588                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1589                                    }
1590                                    else {
1591                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1592                                    }
1593                            }
1594    
1595                            String sql = query.toString();
1596    
1597                            Session session = null;
1598    
1599                            try {
1600                                    session = openSession();
1601    
1602                                    Query q = session.createQuery(sql);
1603    
1604                                    QueryPos qPos = QueryPos.getInstance(q);
1605    
1606                                    if (uuid != null) {
1607                                            qPos.add(uuid);
1608                                    }
1609    
1610                                    count = (Long)q.uniqueResult();
1611                            }
1612                            catch (Exception e) {
1613                                    throw processException(e);
1614                            }
1615                            finally {
1616                                    if (count == null) {
1617                                            count = Long.valueOf(0);
1618                                    }
1619    
1620                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1621                                            finderArgs, count);
1622    
1623                                    closeSession(session);
1624                            }
1625                    }
1626    
1627                    return count.intValue();
1628            }
1629    
1630            /**
1631             * Returns the number of m d r rules where uuid = &#63; and groupId = &#63;.
1632             *
1633             * @param uuid the uuid
1634             * @param groupId the group ID
1635             * @return the number of matching m d r rules
1636             * @throws SystemException if a system exception occurred
1637             */
1638            public int countByUUID_G(String uuid, long groupId)
1639                    throws SystemException {
1640                    Object[] finderArgs = new Object[] { uuid, groupId };
1641    
1642                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1643                                    finderArgs, this);
1644    
1645                    if (count == null) {
1646                            StringBundler query = new StringBundler(3);
1647    
1648                            query.append(_SQL_COUNT_MDRRULE_WHERE);
1649    
1650                            if (uuid == null) {
1651                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1652                            }
1653                            else {
1654                                    if (uuid.equals(StringPool.BLANK)) {
1655                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1656                                    }
1657                                    else {
1658                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1659                                    }
1660                            }
1661    
1662                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1663    
1664                            String sql = query.toString();
1665    
1666                            Session session = null;
1667    
1668                            try {
1669                                    session = openSession();
1670    
1671                                    Query q = session.createQuery(sql);
1672    
1673                                    QueryPos qPos = QueryPos.getInstance(q);
1674    
1675                                    if (uuid != null) {
1676                                            qPos.add(uuid);
1677                                    }
1678    
1679                                    qPos.add(groupId);
1680    
1681                                    count = (Long)q.uniqueResult();
1682                            }
1683                            catch (Exception e) {
1684                                    throw processException(e);
1685                            }
1686                            finally {
1687                                    if (count == null) {
1688                                            count = Long.valueOf(0);
1689                                    }
1690    
1691                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1692                                            finderArgs, count);
1693    
1694                                    closeSession(session);
1695                            }
1696                    }
1697    
1698                    return count.intValue();
1699            }
1700    
1701            /**
1702             * Returns the number of m d r rules where ruleGroupId = &#63;.
1703             *
1704             * @param ruleGroupId the rule group ID
1705             * @return the number of matching m d r rules
1706             * @throws SystemException if a system exception occurred
1707             */
1708            public int countByRuleGroupId(long ruleGroupId) throws SystemException {
1709                    Object[] finderArgs = new Object[] { ruleGroupId };
1710    
1711                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
1712                                    finderArgs, this);
1713    
1714                    if (count == null) {
1715                            StringBundler query = new StringBundler(2);
1716    
1717                            query.append(_SQL_COUNT_MDRRULE_WHERE);
1718    
1719                            query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
1720    
1721                            String sql = query.toString();
1722    
1723                            Session session = null;
1724    
1725                            try {
1726                                    session = openSession();
1727    
1728                                    Query q = session.createQuery(sql);
1729    
1730                                    QueryPos qPos = QueryPos.getInstance(q);
1731    
1732                                    qPos.add(ruleGroupId);
1733    
1734                                    count = (Long)q.uniqueResult();
1735                            }
1736                            catch (Exception e) {
1737                                    throw processException(e);
1738                            }
1739                            finally {
1740                                    if (count == null) {
1741                                            count = Long.valueOf(0);
1742                                    }
1743    
1744                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
1745                                            finderArgs, count);
1746    
1747                                    closeSession(session);
1748                            }
1749                    }
1750    
1751                    return count.intValue();
1752            }
1753    
1754            /**
1755             * Returns the number of m d r rules.
1756             *
1757             * @return the number of m d r rules
1758             * @throws SystemException if a system exception occurred
1759             */
1760            public int countAll() throws SystemException {
1761                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1762                                    FINDER_ARGS_EMPTY, this);
1763    
1764                    if (count == null) {
1765                            Session session = null;
1766    
1767                            try {
1768                                    session = openSession();
1769    
1770                                    Query q = session.createQuery(_SQL_COUNT_MDRRULE);
1771    
1772                                    count = (Long)q.uniqueResult();
1773                            }
1774                            catch (Exception e) {
1775                                    throw processException(e);
1776                            }
1777                            finally {
1778                                    if (count == null) {
1779                                            count = Long.valueOf(0);
1780                                    }
1781    
1782                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1783                                            FINDER_ARGS_EMPTY, count);
1784    
1785                                    closeSession(session);
1786                            }
1787                    }
1788    
1789                    return count.intValue();
1790            }
1791    
1792            /**
1793             * Initializes the m d r rule persistence.
1794             */
1795            public void afterPropertiesSet() {
1796                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1797                                            com.liferay.portal.util.PropsUtil.get(
1798                                                    "value.object.listener.com.liferay.portlet.mobiledevicerules.model.MDRRule")));
1799    
1800                    if (listenerClassNames.length > 0) {
1801                            try {
1802                                    List<ModelListener<MDRRule>> listenersList = new ArrayList<ModelListener<MDRRule>>();
1803    
1804                                    for (String listenerClassName : listenerClassNames) {
1805                                            listenersList.add((ModelListener<MDRRule>)InstanceFactory.newInstance(
1806                                                            listenerClassName));
1807                                    }
1808    
1809                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1810                            }
1811                            catch (Exception e) {
1812                                    _log.error(e);
1813                            }
1814                    }
1815            }
1816    
1817            public void destroy() {
1818                    EntityCacheUtil.removeCache(MDRRuleImpl.class.getName());
1819                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1820                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1821            }
1822    
1823            @BeanReference(type = MDRActionPersistence.class)
1824            protected MDRActionPersistence mdrActionPersistence;
1825            @BeanReference(type = MDRRulePersistence.class)
1826            protected MDRRulePersistence mdrRulePersistence;
1827            @BeanReference(type = MDRRuleGroupPersistence.class)
1828            protected MDRRuleGroupPersistence mdrRuleGroupPersistence;
1829            @BeanReference(type = MDRRuleGroupInstancePersistence.class)
1830            protected MDRRuleGroupInstancePersistence mdrRuleGroupInstancePersistence;
1831            @BeanReference(type = ResourcePersistence.class)
1832            protected ResourcePersistence resourcePersistence;
1833            @BeanReference(type = UserPersistence.class)
1834            protected UserPersistence userPersistence;
1835            private static final String _SQL_SELECT_MDRRULE = "SELECT mdrRule FROM MDRRule mdrRule";
1836            private static final String _SQL_SELECT_MDRRULE_WHERE = "SELECT mdrRule FROM MDRRule mdrRule WHERE ";
1837            private static final String _SQL_COUNT_MDRRULE = "SELECT COUNT(mdrRule) FROM MDRRule mdrRule";
1838            private static final String _SQL_COUNT_MDRRULE_WHERE = "SELECT COUNT(mdrRule) FROM MDRRule mdrRule WHERE ";
1839            private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrRule.uuid IS NULL";
1840            private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrRule.uuid = ?";
1841            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrRule.uuid IS NULL OR mdrRule.uuid = ?)";
1842            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrRule.uuid IS NULL AND ";
1843            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrRule.uuid = ? AND ";
1844            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrRule.uuid IS NULL OR mdrRule.uuid = ?) AND ";
1845            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrRule.groupId = ?";
1846            private static final String _FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2 = "mdrRule.ruleGroupId = ?";
1847            private static final String _ORDER_BY_ENTITY_ALIAS = "mdrRule.";
1848            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRRule exists with the primary key ";
1849            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRRule exists with the key {";
1850            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1851            private static Log _log = LogFactoryUtil.getLog(MDRRulePersistenceImpl.class);
1852            private static MDRRule _nullMDRRule = new MDRRuleImpl() {
1853                            @Override
1854                            public Object clone() {
1855                                    return this;
1856                            }
1857    
1858                            @Override
1859                            public CacheModel<MDRRule> toCacheModel() {
1860                                    return _nullMDRRuleCacheModel;
1861                            }
1862                    };
1863    
1864            private static CacheModel<MDRRule> _nullMDRRuleCacheModel = new CacheModel<MDRRule>() {
1865                            public MDRRule toEntityModel() {
1866                                    return _nullMDRRule;
1867                            }
1868                    };
1869    }