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