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